<script setup lang="ts">
import TheWelcome from '../components/TheWelcome.vue'
import {ref} from 'vue'

const user = ref("");
const password = ref("")
function login(){
  fetch("/api/login", {
    method: 'post',
    body: JSON.stringify({user: user.value, passwd: password.value}),
    headers: {
      'Content-Type': 'application/json'
    }
  }).then(function (data){
    return data.text();
  }).then(function (data){
    console.log(data)
  })
}
</script>

<template>
  <main>
    <form >
      <label for="用户"><input type="text" v-model="user" placeholder="账号"  name="username"></label>
      <label for="密码"><input type="password" v-model="password" placeholder="密码" name="password"></label>
      <label for="登录"><input type="button" value="登录" @click="login"></label>
    </form>
    <a href="/api/user">xx</a>
  </main>
</template>
